/**
 * iWeb2GooglePages - Converts export iWeb content and uploads it to GPs.
 * Copyright (C) 2008 Will Droste
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>. 
 */
package org.iweb2gps;

public class StringUtil {

    /**
     * Determines if a string is empty. Empty is defined as null or empty
     * string.
     * 
     * <pre>
     *  StringUtil.isEmpty(null)               = true
     *  StringUtil.isEmpty(&quot;&quot;)       = true
     *  StringUtil.isEmpty(&quot; &quot;)      = false
     *  StringUtil.isEmpty(&quot;bob&quot;)    = false
     *  StringUtil.isEmpty(&quot; bob &quot;)  = false
     * </pre>
     * 
     * @param val
     *            string to evaluate as empty.
     * @return true if the string is empty else false.
     */
    public static boolean isEmpty(String val) {
        return (val == null) ? true : "".equals(val) ? true : false;
    }

    /**
     * Determines if a string is not empty. Its the exact opposite for
     * {@link #isEmpty(String)}.
     * 
     * @param val
     *            string to evaluate.
     * @return true if the string is not empty
     */
    public static boolean isNotEmpty(String val) {
        return !isEmpty(val);
    }

    /**
     * <pre>
     *      StringUtil.isBlank(null)                = true
     *      StringUtil.isBlank(&quot;&quot;)        = true
     *      StringUtil.isBlank(&quot; &quot;)       = true
     *      StringUtil.isBlank(&quot;bob&quot;)     = false
     *      StringUtil.isBlank(&quot;  bob  &quot;) = false
     * </pre>
     */
    public static boolean isBlank(String val) {
        return (val == null) ? true : isEmpty(val.trim());
    }

    public static boolean isNotBlank(String val) {
        return !isBlank(val);
    }
}